/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_PlayerController_H__
#define __PQ_PlayerController_H__

#include "PlayerUnit.h"

namespace PQClient
{
	/*create player and control it
	*/
	class PlayerController
	{
	public:
		PlayerController(PQEngine::SceneObject *sceneObject);

		void update(float deltaT);
		void setCamera();
		void keepOnGround();
		void updateCamera( float deltaT );
		void setAnims();
	protected:
		SceneObject *_sceneObject;
		PlayerUnit* _playerUnit;

		Ogre::RaySceneQuery* _rayQuery;
		Ogre::SceneNode* _cameraPivot;
		Ogre::SceneNode* _cameraGoal;
		Ogre::SceneNode* _cameraNode;

		float pivotPitch;

		Ogre::Vector3 keyDirection;      // player's local intended direction based on WASD keys
		Ogre::Vector3 goalDirection;     // actual intended direction in world-space

	public:
		void injectMouseMove(const OIS::MouseEvent& evt);
		void injectKeyDown(const OIS::KeyEvent& evt);
		void injectKeyUp(const OIS::KeyEvent& evt);
		void injectMouseDown(const OIS::MouseEvent& evt, OIS::MouseButtonID id);
		void updateCameraGoal(Ogre::Real deltaYaw, Ogre::Real deltaPitch, Ogre::Real deltaZoom);
		void updateBody( float deltaT );
	};

}
#endif
